package com.umeox.watch.moto.gallery.db;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.umeox.watch.moto.gallery.base.BaseApp;
import com.umeox.watch.moto.gallery.db.dao.AlbumInfoDao;
import com.umeox.watch.moto.gallery.db.model.AlbumInfo;

/**
 * Created by Rambo 2021/10/18
 * Describe:
 */
@Database(entities = {AlbumInfo.class}, version = 1, exportSchema = false)
public abstract class AppDataBase extends RoomDatabase {

    private static AppDataBase INSTANCE;
    private static final Object sLock = new Object();

    public static AppDataBase getInstance() {
        synchronized (sLock) {
            if (INSTANCE == null) {

                INSTANCE = Room.databaseBuilder(BaseApp.Companion.getContext().getApplicationContext(),
                        AppDataBase.class, "gallery_info.db")
                        .allowMainThreadQueries()
                        .build();
            }
            return INSTANCE;
        }
    }

    public abstract AlbumInfoDao albumInfoDao();
}
